package com.Hsu.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author Hsu琛君珩
 * @ClassName:BeanConfig
 * @date 2023-12-04
 * @apiNote
 * @Version: v1.0
 */

@Configuration
public class BeanConfig {
    @Bean
    public String name(){
       return "zhangsan";
    }
    //使用@@Primary指定bean
    //@Primary
    @Bean({"u1","user1"})
    public UserInfo userInfo1(){
        UserInfo userInfo=new UserInfo();
        userInfo.setId(1);
        userInfo.setName("zhangsan");
        userInfo.setAge(12);
        return userInfo;
    }
    @Bean("u2")
    public UserInfo userInfo2(){
        UserInfo userInfo=new UserInfo();
        userInfo.setId(2);
        userInfo.setName("lisi");
        userInfo.setAge(13);
        return userInfo;
    }
}
